import pygame

canvas = pygame.display.set_mode((480, 650))


##############创建一个工厂(创建飞机)类################

class Plane():
    # 飞机->属性：x,y,skin,width,height,方法：飞行（从上往下飞）
    def __init__(self,x,y,skin,width,height,type,health = 100):
        self.x = x
        self.y = y
        self.skin = skin
        self.width = width
        self.height = height
        self.type = type
        self.health = health
        self.bullets = []  # 存储该敌机发射的子弹
    def fly(self):
        self.y = self.y + 2

    def draw_health_bar(self, x, y, health_bar_width, health_bar_height, color=(255, 0, 0)):
        pygame.draw.rect(canvas, color, (x, y, health_bar_width * (self.health / 100), health_bar_height))
